home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / videbjct / videoobj.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  27.7 KB  |  1,171 lines

  1. /*
  2.  * Copyright (c) 1990, 1991, 1992 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/VideoObject/RCS/videoObj.c,v 0.29 92/09/02 17:09:43 drapeau Exp $ */
  25. /* $Log:    videoObj.c,v $
  26.  * Revision 0.29  92/09/02  17:09:43  drapeau
  27.  * Fixed code for determining what terminal parameters to use for serial
  28.  * communications, especially when parity and flow control are concerned.
  29.  * Previous versions of this code did not handle flow control and parity
  30.  * correctly.
  31.  * 
  32.  * Revision 0.28  92/09/01  16:58:10  drapeau
  33.  * Cosmetic changes to the code to make it easier to read.  Also, added
  34.  * function prototypes to make code more ANSI-compliant.
  35.  * 
  36.  * Revision 0.27  92/07/30  15:14:46  drapeau
  37.  * Removed window system-specific code, to make library more portable.
  38.  * Also, minor cosmetic changes to enhance code readability.
  39.  * Also, minor changes to diagnostic messages to improve readability.
  40.  * 
  41.  * Revision 0.26  92/06/17  01:01:58  drapeau
  42.  * Changed termio usage, used more portable "termio" structure and
  43.  * associated calls instead of "termios".
  44.  * 
  45.  * Revision 0.25  91/09/30  17:08:58  lim
  46.  * Implemented DevPing, DefaultPing, PlayerVerified.
  47.  * 
  48.  * Revision 0.24  91/08/24  17:50:28  lim
  49.  * Implemented PrintDiagnostics.
  50.  * 
  51.  * Revision 0.23  91/08/24  13:52:13  lim
  52.  * CheckImplemented corrected to return an enum Boolean.
  53.  * 
  54.  * Revision 0.22  91/08/24  13:39:20  lim
  55.  * 1. Clear Marker() removed as part of video Object.
  56.  * 
  57.  * Revision 0.21  91/08/20  10:06:41  lim
  58.  * Removed InterruptibleSegmentPlay from BuildVideoObject.
  59.  * 
  60.  * Revision 0.20  91/08/17  20:42:08  lim
  61.  * 1. Removed 'interruptibleSegmentPlay' from video object. All stops and
  62.  * pauses must be implemented such that they can interrupt segment play.
  63.  * 
  64.  * Revision 0.19  91/08/16  13:14:52  lim
  65.  * Each Dev<Function> call now checks if theObject is valid.
  66.  * 
  67.  * Revision 0.18  91/08/08  17:19:37  lim
  68.  * 1. CalcSpeed() - one parameter added, 'playMode'. If playMode is 1, it is used to calculate
  69.  *    device speed for segment play. If playMode is 0, it is used to calculate device speed for
  70.  *    normal play.
  71.  * 2. QueryMedium() - one parameter added, 'result'. Used to return non-integer results.
  72.  * 
  73.  * Revision 0.17  91/08/07  13:30:24  lim
  74.  * 1. Added instance pointer, "theObject" to all public function calls.
  75.  * 2. Added file descriptor field to structure 'Config'.
  76.  * 3. ErrorDecode is now a private function, and thus removed from the
  77.  * VideoObject.
  78.  * 4. BuildVideoObject now returns pointer to VideoObject.
  79.  * 
  80.  * Revision 0.16  91/08/02  13:02:53  lim
  81.  * 1. No more GetDevices - Device configurations stored in each device's
  82.  * videoObject, and names of all devices stored in allDevices.
  83.  * 2. 'myVideo' is now globally accessible.
  84.  * 3. SetSerialLine changed to take in device configuration structure as
  85.  * first parameter rather than device name.
  86.  * 4. BuildVideoObject changed to include new field in videoObject - the
  87.  * configuration.
  88.  * 5. Pause() has been removed from videoObject's functions.
  89.  * 6. Added : GetDeviceMaxSpeed - gets the max speed on current device.
  90.  *            CheckImplemented - checks if particular function available on
  91.  *                               current device.
  92.  * 7. DevSetDefaults now takes 4 parameters.
  93.  * 
  94.  * Revision 0.15  91/07/29  22:31:57  lim
  95.  * When there is no eol char, the line will be set up to 
  96.  * 1. Ignore carriage return IGNCR
  97.  * 2. Non-canonical input
  98.  * 3. c_cc[VMIN] is set to default 1, and c_cc[VTIME] to 0.
  99.  * 
  100.  * Revision 0.14  91/07/27  22:30:05  lim
  101.  * Changed speed from double to int.
  102.  * 
  103.  * Revision 0.13  91/07/23  15:59:47  lim
  104.  * 1. Changed static variables to globals.
  105.  * 2. Introduced a new field, interruptibleSegmentPlay, in the .VideoConfig
  106.  * file, to denote whether device supports interruptible segment playing.
  107.  * 
  108.  * 
  109.  * Revision 0.12  91/07/19  14:16:11  lim
  110.  * Added speed field to PlayFromTo.
  111.  * 
  112.  * Revision 0.11  91/07/17  22:50:55  lim
  113.  * Removed function from VideoObject, "SetSerialPort". 
  114.  * 
  115.  * Revision 0.10  91/07/12  16:22:36  lim
  116.  * Initial revision implementing VideoObject.
  117.  *  */
  118.  
  119. #include "videoObj.h"
  120.  
  121.  
  122. static Config DefaultConfig = 
  123. {
  124.   "NOTHING",
  125.   "na",
  126.   0,
  127.   -1,
  128.   -1,
  129.   Even,
  130.   Yes,
  131.   Yes,
  132.   -1,
  133.   -1
  134.   }
  135.  
  136.  
  137. static VideoObject DefaultObj = 
  138. {
  139.   &DefaultConfig,
  140.   DefaultPlay,
  141.   DefaultPlayFromTo,
  142.   DefaultFastForward,
  143.   DefaultReverse,
  144.   DefaultCalcSpeed,
  145.   DefaultPlayAtSpeedDir,
  146.   DefaultStep,
  147.   DefaultStill,
  148.   DefaultStop,
  149.   DefaultSetDefaults,
  150.   DefaultSetAudio,
  151.   DefaultSetVideo,
  152.   DefaultSetAddMode,
  153.   DefaultSetAddressDisplay,
  154.   DefaultEject,
  155.   DefaultPower,
  156.   DefaultQueryFrame,
  157.   DefaultQueryChapter,
  158.   DefaultQueryAudio,
  159.   DefaultQueryVideo,
  160.   DefaultQueryMedium,
  161.   DefaultQueryStatus,
  162.   DefaultPing,
  163.   DefaultRecord,
  164.   DefaultRecordFromTo
  165.   }
  166. ;
  167.  
  168.  
  169. /* Sets up serial line for device selected.  
  170.  * Returns file descriptor.
  171.  */
  172.  
  173. int
  174.   SetSerialLine(Config*    configuration,
  175.         char*    newSerialLine)
  176. {
  177.   int ibaud;
  178.   int bits;
  179.   int serialLine;
  180.   char diagMsg[30];
  181.   static struct termio lineAttributes;
  182.   
  183.   if (configuration->fd>=0)                        /* Close previous serial line */
  184.     close (configuration->fd);
  185.   
  186.   switch (configuration->baudRate) 
  187.   {
  188.    case 300:
  189.     ibaud = B300;
  190.     break;
  191.    case 1200:
  192.     ibaud = B1200;
  193.     break;
  194.    case 2400:
  195.     ibaud = B2400;
  196.     break;
  197.    case 4800:
  198.     ibaud = B4800;
  199.     break;
  200.    case 9600:
  201.     ibaud = B9600;
  202.     break;
  203.    default:
  204.     PrintDiagnostics("Illegal baud rate\n");
  205.   }
  206.   
  207.   switch (configuration->charSize)
  208.   {
  209.    case 5:
  210.     bits = CS5;
  211.     break;
  212.    case 6:
  213.     bits = CS6;
  214.     break;
  215.    case 7:
  216.     bits = CS7;
  217.     break;
  218.    case 8:
  219.     bits = CS8;
  220.     break;
  221.    default:
  222.     PrintDiagnostics("Illegal character size\n");
  223.   }
  224.   
  225.   /* Open serial line */
  226.   
  227.   if (newSerialLine)                            /* newSerialLine overrides all other settings */
  228.     strcpy(configuration->serialPort, newSerialLine);
  229.   else
  230.     PrintDiagnostics("No entry in defaults file.\n");
  231.   
  232.   if ((serialLine = open(configuration->serialPort, O_RDWR)) == -1) 
  233.     PrintDiagnostics("VideoObject: Cannot open serial line for communications.\n");
  234.   
  235.   lineAttributes.c_iflag = 0;
  236.   if (configuration->flowControl == Yes)
  237.   {
  238.     lineAttributes.c_iflag |= IXON;
  239.     lineAttributes.c_iflag |= IXOFF;
  240.   }
  241.   if (configuration->igParError == Yes)
  242.     lineAttributes.c_iflag |= IGNPAR;
  243.   if (configuration->parity != NoParity)
  244.     lineAttributes.c_iflag |= INPCK;
  245.   if (configuration->eolChar < 0)
  246.     lineAttributes.c_iflag |= IGNCR;
  247.   
  248.   lineAttributes.c_oflag = 0;
  249.   lineAttributes.c_lflag = 0;
  250.   if (configuration->eolChar >= 0)                    /* Canonical input processing only if there is a eol char */
  251.     lineAttributes.c_lflag |= ICANON;
  252.   lineAttributes.c_line = 0;
  253.   
  254.   if (configuration->eolChar >= 0)                    /* Player has end-of-line character */
  255.     lineAttributes.c_cc[VEOL] = configuration->eolChar;
  256.   else                                    /* Player has no end-of-line character */
  257.   {
  258.     lineAttributes.c_cc[VMIN] = 1;
  259.     lineAttributes.c_cc[VTIME] = 0;
  260.   }
  261.   
  262.   lineAttributes.c_cflag = 0;
  263.   lineAttributes.c_cflag |= ibaud;
  264.   lineAttributes.c_cflag |= bits;
  265.   lineAttributes.c_cflag |= CLOCAL;
  266.   lineAttributes.c_cflag |= CREAD;
  267.   if (configuration->parity != NoParity)
  268.     lineAttributes.c_cflag |= PARENB;
  269.   if (configuration->parity == Odd)
  270.     lineAttributes.c_cflag |= PARODD;
  271.   
  272.   if (ioctl(serialLine,TCSETA,(char*)&lineAttributes) == -1) 
  273.     PrintDiagnostics("Can't set line attributes.\n");
  274.   
  275.   configuration->fd = serialLine;
  276.   return serialLine;
  277. }                                    /* end function SetSerialLine */
  278.  
  279.  
  280. /* To test if player & serial port are correctly selected.
  281.  * A serial line is set up so that it does non-canonical input
  282.  * processing, with a timer set to TimeOut seconds, and the read returning
  283.  * after the first character is read. 
  284.  * The function DevPing() is called for the object installed.
  285.  * If DevPing() returns a positive number, it means that the device is
  286.  * correct, and PlayerVerified returns 1.  
  287.  * If DevPing() returns 0 or a negative number, it means that the read 
  288.  * has timed out, and either the player is too busy to respond, or the
  289.  * wrong player has been selected, or the wrong serial port has been 
  290.  * selected, or the wrong line attributes (eg baud rate) have been set. 
  291.  * In this case, PlayerVerified returns -1.
  292.  */
  293. int
  294. PlayerVerified(VideoObject*    theObject,
  295.            char*        sLine)
  296. {
  297.   struct termio    lineAttributes;
  298.   int        numRead;
  299.   int        eolChar;                                
  300.   int        result = 0;
  301.   char        out[5];
  302.   
  303.   eolChar = theObject->DevConfig->eolChar;                /* We must keep tmp copy of eolChar */
  304.   theObject->DevConfig->eolChar = -1;                    /* For non-canonical processing */
  305.   
  306.   if (SetSerialLine(theObject->DevConfig, sLine))
  307.   {
  308.     result = ioctl(theObject->DevConfig->fd,TCGETA,
  309.            (char*)&lineAttributes);
  310.     lineAttributes.c_cc[VMIN] = 0;
  311.     lineAttributes.c_cc[VTIME] = TimeOut*10;                /* VTIME is in 0.1 seconds */
  312.     result = ioctl(theObject->DevConfig->fd,TCSETA,
  313.            (char*)&lineAttributes);
  314.     if (result == -1)
  315.       return -1;
  316.     
  317.     numRead = DevPing(theObject);
  318.     close(theObject->DevConfig->fd);
  319.     theObject->DevConfig->fd = -1;                    /* Reset file descriptor */
  320.     theObject->DevConfig->eolChar = eolChar;                /* Reset eolChar */
  321.     
  322.     if (numRead > 0)
  323.       return 1;
  324.     else
  325.       return -1;
  326.   }
  327.   else
  328.     return -1;
  329. }
  330.  
  331.  
  332. /* Builds the Video Object for use by application.
  333.  * A copy of the defined functions in the new device ...
  334.  * ... is made to theObject.
  335.  */
  336.  
  337. VideoObject* 
  338.   BuildVideoObject(VideoObject* videoObj)
  339. {
  340.   VideoObject* newObj;
  341.   
  342.   newObj = (VideoObject*) malloc(sizeof(VideoObject));
  343.   newObj->DevConfig = (Config*) malloc(sizeof(Config));
  344.   
  345.   strcpy(newObj->DevConfig->serialPort, videoObj->DevConfig->serialPort);
  346.   strcpy(newObj->DevConfig->modelName, videoObj->DevConfig->modelName);
  347.   newObj->DevConfig->baudRate = videoObj->DevConfig->baudRate;
  348.   newObj->DevConfig->eolChar = videoObj->DevConfig->eolChar;
  349.   newObj->DevConfig->charSize = videoObj->DevConfig->charSize;
  350.   newObj->DevConfig->parity = videoObj->DevConfig->parity;
  351.   newObj->DevConfig->igParError = videoObj->DevConfig->igParError;
  352.   newObj->DevConfig->maxSpeed = videoObj->DevConfig->maxSpeed;
  353.   newObj->DevConfig->fd = videoObj->DevConfig->fd;
  354.   
  355.   if (videoObj->DevPlayPtr)
  356.     newObj->DevPlayPtr =  videoObj->DevPlayPtr; 
  357.   else
  358.     newObj->DevPlayPtr =  DefaultObj.DevPlayPtr; 
  359.   
  360.   if (videoObj->DevPlayFromToPtr)
  361.     newObj->DevPlayFromToPtr =  videoObj->DevPlayFromToPtr; 
  362.   else
  363.     newObj->DevPlayFromToPtr =  DefaultObj.DevPlayFromToPtr; 
  364.   
  365.   if (videoObj->DevFastForwardPtr)
  366.     newObj->DevFastForwardPtr =  videoObj->DevFastForwardPtr; 
  367.   else
  368.     newObj->DevFastForwardPtr =  DefaultObj.DevFastForwardPtr; 
  369.   
  370.   if (videoObj->DevReversePtr)
  371.     newObj->DevReversePtr =  videoObj->DevReversePtr; 
  372.   else
  373.     newObj->DevReversePtr =  DefaultObj.DevReversePtr; 
  374.   
  375.   if (videoObj->DevCalcSpeedPtr)
  376.     newObj->DevCalcSpeedPtr =  videoObj->DevCalcSpeedPtr; 
  377.   else
  378.     newObj->DevCalcSpeedPtr =  DefaultObj.DevCalcSpeedPtr; 
  379.   
  380.   if (videoObj->DevPlayAtSpeedDirPtr)
  381.     newObj->DevPlayAtSpeedDirPtr =  videoObj->DevPlayAtSpeedDirPtr; 
  382.   else
  383.     newObj->DevPlayAtSpeedDirPtr =  DefaultObj.DevPlayAtSpeedDirPtr; 
  384.   
  385.   if (videoObj->DevStepPtr)
  386.     newObj->DevStepPtr =  videoObj->DevStepPtr; 
  387.   else
  388.     newObj->DevStepPtr =  DefaultObj.DevStepPtr; 
  389.   
  390.   if (videoObj->DevStillPtr)
  391.     newObj->DevStillPtr =  videoObj->DevStillPtr; 
  392.   else
  393.     newObj->DevStillPtr =  DefaultObj.DevStillPtr; 
  394.   
  395.   if (videoObj->DevStopPtr)
  396.     newObj->DevStopPtr =  videoObj->DevStopPtr; 
  397.   else
  398.     newObj->DevStopPtr =  DefaultObj.DevStopPtr; 
  399.   
  400.   if (videoObj->DevSetDefaultsPtr)
  401.     newObj->DevSetDefaultsPtr =  videoObj->DevSetDefaultsPtr; 
  402.   else
  403.     newObj->DevSetDefaultsPtr =  DefaultObj.DevSetDefaultsPtr; 
  404.   
  405.   if (videoObj->DevSetAudioPtr)
  406.     newObj->DevSetAudioPtr =  videoObj->DevSetAudioPtr; 
  407.   else
  408.     newObj->DevSetAudioPtr =  DefaultObj.DevSetAudioPtr; 
  409.   
  410.   if (videoObj->DevSetVideoPtr)
  411.     newObj->DevSetVideoPtr =  videoObj->DevSetVideoPtr;
  412.   else
  413.     newObj->DevSetVideoPtr =  DefaultObj.DevSetVideoPtr;
  414.   
  415.   if (videoObj->DevSetAddModePtr)
  416.     newObj->DevSetAddModePtr =  videoObj->DevSetAddModePtr;
  417.   else
  418.     newObj->DevSetAddModePtr =  DefaultObj.DevSetAddModePtr;
  419.   
  420.   if (videoObj->DevSetAddressDisplayPtr)
  421.     newObj->DevSetAddressDisplayPtr =  videoObj->DevSetAddressDisplayPtr; 
  422.   else
  423.     newObj->DevSetAddressDisplayPtr =  DefaultObj.DevSetAddressDisplayPtr; 
  424.   
  425.   if (videoObj->DevEjectPtr)
  426.     newObj->DevEjectPtr =  videoObj->DevEjectPtr;
  427.   else
  428.     newObj->DevEjectPtr =  DefaultObj.DevEjectPtr;
  429.   
  430.   if (videoObj->DevPowerPtr)
  431.     newObj->DevPowerPtr =  videoObj->DevPowerPtr; 
  432.   else
  433.     newObj->DevPowerPtr =  DefaultObj.DevPowerPtr; 
  434.   
  435.   if (videoObj->DevQueryFramePtr)
  436.     newObj->DevQueryFramePtr =  videoObj->DevQueryFramePtr; 
  437.   else
  438.     newObj->DevQueryFramePtr =  DefaultObj.DevQueryFramePtr; 
  439.   
  440.   if (videoObj->DevQueryChapterPtr)
  441.     newObj->DevQueryChapterPtr =  videoObj->DevQueryChapterPtr; 
  442.   else
  443.     newObj->DevQueryChapterPtr =  DefaultObj.DevQueryChapterPtr; 
  444.   
  445.   if (videoObj->DevQueryAudioPtr)
  446.     newObj->DevQueryAudioPtr =  videoObj->DevQueryAudioPtr; 
  447.   else
  448.     newObj->DevQueryAudioPtr =  DefaultObj.DevQueryAudioPtr; 
  449.   
  450.   if (videoObj->DevQueryVideoPtr)
  451.     newObj->DevQueryVideoPtr =  videoObj->DevQueryVideoPtr; 
  452.   else
  453.     newObj->DevQueryVideoPtr =  DefaultObj.DevQueryVideoPtr; 
  454.   
  455.   if (videoObj->DevQueryMediumPtr)
  456.     newObj->DevQueryMediumPtr =    videoObj->DevQueryMediumPtr; 
  457.   else
  458.     newObj->DevQueryMediumPtr =    DefaultObj.DevQueryMediumPtr; 
  459.   
  460.   if (videoObj->DevQueryStatusPtr)
  461.     newObj->DevQueryStatusPtr =  videoObj->DevQueryStatusPtr;
  462.   else
  463.     newObj->DevQueryStatusPtr =  DefaultObj.DevQueryStatusPtr;
  464.   
  465.   if (videoObj->DevPingPtr)
  466.     newObj->DevPingPtr =  videoObj->DevPingPtr;
  467.   else
  468.     newObj->DevPingPtr =  DefaultObj.DevPingPtr;
  469.   
  470.   if (videoObj->DevRecordPtr)
  471.     newObj->DevRecordPtr =  videoObj->DevRecordPtr;
  472.   else
  473.     newObj->DevRecordPtr =  DefaultObj.DevRecordPtr;
  474.   
  475.   if (videoObj->DevRecordFromToPtr)
  476.     newObj->DevRecordFromToPtr =  videoObj->DevRecordFromToPtr;
  477.   else
  478.     newObj->DevRecordFromToPtr =  DefaultObj.DevRecordFromToPtr;
  479.   
  480.   return (newObj);
  481. }                                    /* end function BuildVideoObject */
  482.  
  483.  
  484.  
  485. /* Returns the max speed for the current video device */
  486. int
  487.   GetDeviceMaxSpeed(VideoObject* theObject)
  488. {
  489.   if (theObject)
  490.     return (theObject->DevConfig->maxSpeed);
  491.   else 
  492.     return -1;
  493. }
  494.  
  495.  
  496. /* Checks to see if video object function 'func' has been implemented...
  497.  * ... in current video object */
  498. enum Boolean
  499.   CheckImplemented(VideoObject*    theObject,
  500.            int        func)
  501. {
  502.   switch (func)
  503.   {
  504.    case PlayFunction:
  505.     if (theObject->DevPlayPtr)
  506.       return Yes;
  507.     else
  508.       return No;
  509.    case PlayFromToFunction:
  510.     if (theObject->DevPlayFromToPtr)
  511.       return Yes;
  512.     else
  513.       return No;
  514.    case FastForwardFunction:
  515.     if (theObject->DevFastForwardPtr)
  516.       return Yes;
  517.     else
  518.       return No;
  519.    case ReverseFunction:
  520.     if (theObject->DevReversePtr)
  521.       return Yes;
  522.     else
  523.       return No;
  524.    case CalcSpeedFunction:
  525.     if (theObject->DevCalcSpeedPtr)
  526.       return Yes;
  527.     else
  528.       return No;
  529.    case PlayAtSpeedDirFunction:
  530.     if (theObject->DevPlayAtSpeedDirPtr)
  531.       return Yes;
  532.     else
  533.       return No;
  534.    case StepFunction:
  535.     if (theObject->DevStepPtr)
  536.       return Yes;
  537.     else
  538.       return No;
  539.    case StillFunction:
  540.     if (theObject->DevStillPtr)
  541.       return Yes;
  542.     else
  543.       return No;
  544.    case StopFunction:
  545.     if (theObject->DevStopPtr)
  546.       return Yes;
  547.     else
  548.       return No;
  549.    case SetDefaultsFunction:
  550.     if (theObject->DevSetDefaultsPtr)
  551.       return Yes;
  552.     else
  553.       return No;
  554.    case SetAudioFunction:
  555.     if (theObject->DevSetAudioPtr)
  556.       return Yes;
  557.     else
  558.       return No;
  559.    case SetVideoFunction:
  560.     if (theObject->DevSetVideoPtr)
  561.       return Yes;
  562.     else
  563.       return No;
  564.    case SetAddModeFunction:
  565.     if (theObject->DevSetAddModePtr)
  566.       return Yes;
  567.     else
  568.       return No;
  569.    case SetAddressDisplayFunction:
  570.     if (theObject->DevSetAddressDisplayPtr)
  571.       return Yes;
  572.     else
  573.       return No;
  574.    case EjectFunction:
  575.     if (theObject->DevEjectPtr)
  576.       return Yes;
  577.     else
  578.       return No;
  579.    case PowerFunction:
  580.     if (theObject->DevPowerPtr)
  581.       return Yes;
  582.     else
  583.       return No;
  584.    case QueryFrameFunction:
  585.     if (theObject->DevQueryFramePtr)
  586.       return Yes;
  587.     else
  588.       return No;
  589.    case QueryChapterFunction:
  590.     if (theObject->DevQueryChapterPtr)
  591.       return Yes;
  592.     else
  593.       return No;
  594.    case QueryAudioFunction:
  595.     if (theObject->DevQueryAudioPtr)
  596.       return Yes;
  597.     else
  598.       return No;
  599.    case QueryVideoFunction:
  600.     if (theObject->DevQueryVideoPtr)
  601.       return Yes;
  602.     else
  603.       return No;
  604.    case QueryMediumFunction:
  605.     if (theObject->DevQueryMediumPtr)
  606.       return Yes;
  607.     else
  608.       return No;
  609.    case QueryStatusFunction:
  610.     if (theObject->DevQueryStatusPtr)
  611.       return Yes;
  612.     else
  613.       return No;
  614.    case PingFunction:
  615.     if (theObject->DevPingPtr)
  616.       return Yes;
  617.     else
  618.       return No;    
  619.    case RecordFunction:
  620.     if (theObject->DevRecordPtr)
  621.       return Yes;
  622.     else
  623.       return No;    
  624.    case RecordFromToFunction:
  625.     if (theObject->DevRecordFromToPtr)
  626.       return Yes;
  627.     else
  628.       return No;    
  629.    default:
  630.     return -1;
  631.   }
  632. }
  633.  
  634.  
  635.  
  636.  
  637. /* Functions of the Video Object */
  638. /* All applications call one of the following generic Dev<Function>s ... 
  639.  * ... which call the appropriate function for the specific device. */
  640.  
  641. int 
  642.   DevPlay(VideoObject* theObject)
  643. {
  644.   if (theObject)
  645.     return ((*theObject->DevPlayPtr) (theObject));  
  646.   else
  647.   {
  648.     fprintf(stderr, "No device driver installed\n");
  649.     return -1;
  650.   }
  651.   
  652. }
  653.  
  654. int 
  655.   DevPlayFromTo(VideoObject*    theObject,
  656.         int        startFrame,
  657.         int        endFrame,
  658.         int        speed)
  659. {
  660.   if (theObject)
  661.     return ((*theObject->DevPlayFromToPtr) (theObject, startFrame, endFrame, speed));
  662.   else
  663.   {
  664.     fprintf(stderr, "No device driver installed\n");
  665.     return -1;
  666.   }
  667. }
  668.  
  669.  
  670. int 
  671.   DevFastForward(VideoObject* theObject)
  672. {
  673.   if (theObject)
  674.     return ((*theObject->DevFastForwardPtr) (theObject));
  675.   else
  676.   {
  677.     fprintf(stderr, "No device driver installed\n");
  678.     return -1;
  679.   }
  680. }
  681.  
  682.  
  683.  
  684. int 
  685.   DevReverse(VideoObject* theObject)
  686. {
  687.   if (theObject)
  688.     return ((*theObject->DevReversePtr) (theObject));
  689.   else
  690.   {
  691.     fprintf(stderr, "No device driver installed\n");
  692.     return -1;
  693.   }
  694. }
  695.  
  696.  
  697. int
  698.   DevCalcSpeed(VideoObject*    theObject,
  699.            int        value,
  700.            int        mode)
  701. {
  702.   if (theObject)
  703.     return ((*theObject->DevCalcSpeedPtr) (theObject, value, mode));
  704.   else
  705.   {
  706.     fprintf(stderr, "No device driver installed\n");
  707.     return -1;
  708.   }
  709. }
  710.  
  711.  
  712. int 
  713.   DevPlayAtSpeedDir(VideoObject*    theObject,
  714.             int            framesPerSecond,
  715.             enum Direction    direction)
  716. {
  717.   if (theObject)
  718.     return ((*theObject->DevPlayAtSpeedDirPtr) (theObject, framesPerSecond, direction));
  719.   else
  720.   {
  721.     fprintf(stderr, "No device driver installed\n");
  722.     return -1;
  723.   }
  724. }
  725.  
  726. int DevStep(VideoObject*    theObject,
  727.         enum Direction    direction)
  728. {
  729.   if (theObject)
  730.     return ((*theObject->DevStepPtr) (theObject, direction));
  731.   else
  732.   {
  733.     fprintf(stderr, "No device driver installed\n");
  734.     return -1;
  735.   }
  736. }
  737.  
  738. int DevStill(VideoObject* theObject)
  739. {
  740.   if (theObject)
  741.     return ((*theObject->DevStillPtr) (theObject));
  742.   else
  743.   {
  744.     fprintf(stderr, "No device driver installed\n");
  745.     return -1;
  746.   }
  747. }
  748.  
  749.  
  750. int DevStop(VideoObject* theObject)
  751. {
  752.   if (theObject)
  753.     return ((*theObject->DevStopPtr) (theObject));
  754.   else
  755.   {
  756.     fprintf(stderr, "No device driver installed\n");
  757.     return -1;
  758.   }
  759. }
  760.  
  761.  
  762. int DevSetDefaults(VideoObject*    theObject,
  763.            int        audio,
  764.            int        addressingMode,
  765.            int        addressDisplayOnOff,
  766.            int        displayMode)
  767. {
  768.   if (theObject)
  769.     return ((*theObject->DevSetDefaultsPtr) (theObject, audio, addressingMode, 
  770.                          addressDisplayOnOff, displayMode));
  771.   else
  772.   {
  773.     fprintf(stderr, "No device driver installed\n");
  774.     return -1;
  775.   }
  776. }
  777.  
  778.  
  779. int DevSetAudio(VideoObject*    theObject,
  780.         int        setting)
  781. {
  782.   if (theObject)
  783.     return ((*theObject->DevSetAudioPtr) (theObject, setting));
  784.   else
  785.   {
  786.     fprintf(stderr, "No device driver installed\n");
  787.     return -1;
  788.   }
  789. }
  790.  
  791.  
  792. int DevSetVideo(VideoObject*    theObject,
  793.         int        setting)
  794. {  
  795.   if (theObject)
  796.     return ((*theObject->DevSetVideoPtr) (theObject, setting));
  797.   else
  798.   {
  799.     fprintf(stderr, "No device driver installed\n");
  800.     return -1;
  801.   }
  802. }
  803.  
  804. int DevSetAddMode(VideoObject*    theObject,
  805.           int        mode)
  806. {
  807.   if (theObject)
  808.     return ((*theObject->DevSetAddModePtr) (theObject, mode));
  809.   else
  810.   {
  811.     fprintf(stderr, "No device driver installed\n");
  812.     return -1;
  813.   }
  814. }
  815.  
  816.  
  817. int DevSetAddressDisplay(VideoObject*    theObject,
  818.              int        onOff,
  819.              int        mode)
  820. {
  821.   if (theObject)
  822.     return ((*theObject->DevSetAddressDisplayPtr) (theObject, onOff, mode));
  823.   else
  824.   {
  825.     fprintf(stderr, "No device driver installed\n");
  826.     return -1;
  827.   }
  828. }
  829.  
  830.  
  831. int DevEject(VideoObject* theObject)
  832. {
  833.   if (theObject)
  834.     return ((*theObject->DevEjectPtr) (theObject));
  835.   else
  836.   {
  837.     fprintf(stderr, "No device driver installed\n");
  838.     return -1;
  839.   }
  840. }
  841.  
  842.  
  843. int DevPower(VideoObject*    theObject,
  844.          int        mode)
  845. {
  846.   if (theObject)
  847.     return ((*theObject->DevPowerPtr) (theObject, mode));
  848.   else
  849.   {
  850.     fprintf(stderr, "No device driver installed\n");
  851.     return -1;
  852.   }
  853. }
  854.  
  855.  
  856. int DevQueryFrame(VideoObject* theObject)
  857. {
  858.   if (theObject)
  859.     return ((*theObject->DevQueryFramePtr) (theObject));
  860.   else
  861.   {
  862.     fprintf(stderr, "No device driver installed\n");
  863.     return -1;
  864.   }
  865. }
  866.  
  867.  
  868. int DevQueryChapter(VideoObject* theObject)
  869. {
  870.   if (theObject)
  871.     return ((*theObject->DevQueryChapterPtr) (theObject));
  872.   else
  873.   {
  874.     fprintf(stderr, "No device driver installed\n");
  875.     return -1;
  876.   }
  877. }
  878.  
  879.  
  880. int DevQueryAudio(VideoObject* theObject)
  881. {
  882.   if (theObject)
  883.     return ((*theObject->DevQueryAudioPtr) (theObject));
  884.   else
  885.   {
  886.     fprintf(stderr, "No device driver installed\n");
  887.     return -1;
  888.   }
  889. }
  890.  
  891.  
  892. int DevQueryVideo(VideoObject* theObject)
  893. {
  894.   if (theObject)
  895.     return ((*theObject->DevQueryVideoPtr) (theObject));
  896.   else
  897.   {
  898.     fprintf(stderr, "No device driver installed\n");
  899.     return -1;
  900.   }
  901. }
  902.  
  903.  
  904. int DevQueryMedium(VideoObject*    theObject,
  905.            char*    result)
  906. {
  907.   if (theObject)
  908.     return ((*theObject->DevQueryMediumPtr) (theObject, result));
  909.   else
  910.   {
  911.     fprintf(stderr, "No device driver installed\n");
  912.     return -1;
  913.   }
  914. }
  915.  
  916.  
  917. int DevQueryStatus(VideoObject*    theObject)
  918. {
  919.   if (theObject)
  920.     return ((*theObject->DevQueryStatusPtr) (theObject));
  921.   else
  922.   {
  923.     fprintf(stderr, "No device driver installed\n");
  924.     return -1;
  925.   }
  926. }
  927.  
  928.  
  929. int DevPing(VideoObject* theObject)
  930. {
  931.   if (theObject)
  932.     return ((*theObject->DevPingPtr) (theObject));
  933.   else
  934.   {
  935.     fprintf(stderr, "No device driver installed\n");
  936.     return -1;
  937.   }
  938. }
  939.  
  940.  
  941. int 
  942.   DevRecord(VideoObject* theObject)
  943. {
  944.   if (theObject)
  945.     return ((*theObject->DevRecordPtr) (theObject));
  946.   else
  947.   {
  948.     fprintf(stderr, "No Record function installed.\n");
  949.     return -1;
  950.   }
  951. }                                    /* end function DevRecord */
  952.  
  953.  
  954.  
  955. int 
  956.   DevRecordFromTo(VideoObject* theObject,
  957.           int startFrame,
  958.           int endFrame,
  959.           int speed)
  960. {
  961.   if (theObject)
  962.     return ((*theObject->DevRecordFromToPtr) (theObject, startFrame, endFrame, speed));
  963.   else
  964.   {
  965.     fprintf(stderr, "No RecordFromTo function installed.\n");
  966.     return -1;
  967.   }
  968. }                                    /* end function DevRecordFromTo */
  969.  
  970.  
  971. /* Default Functions of the Video Object */
  972. /* Functions that are not implemented for the driver and for ...
  973.  * ... which no dummy function has been written by the ...
  974.  * ... the application programmer will use the default ...
  975.  * ... functions.
  976.  */
  977.  
  978. int 
  979.   DefaultPlay(VideoObject* theObject)
  980. {
  981.   fprintf(stderr, "DevPlay has not been implemented.\n");
  982.   return Ok;
  983. }
  984.  
  985. int 
  986.   DefaultPlayFromTo(VideoObject*    theObject,
  987.             int            startFrame,
  988.             int            endFrame,
  989.             int            speed)
  990. {
  991.   fprintf(stderr, "DevPlayFromTo has not been implemented.\n");
  992.   return Ok;
  993. }
  994.  
  995.  
  996. int 
  997.   DefaultFastForward(VideoObject* theObject)
  998. {
  999.   fprintf(stderr, "DevFastForward has not been implemented.\n");
  1000.   return Ok;
  1001. }
  1002.  
  1003.  
  1004.  
  1005. int 
  1006.   DefaultReverse(VideoObject* theObject)
  1007. {
  1008.   fprintf(stderr, "DevReverse has not been implemented.\n");
  1009.   return Ok;
  1010. }
  1011.  
  1012.  
  1013. int
  1014.   DefaultCalcSpeed(VideoObject*    theObject,
  1015.            int        value,
  1016.            int        mode)
  1017. {
  1018.   fprintf(stderr, "DevCalcSpeed has not been implemented.\n");
  1019.   return Ok;
  1020. }
  1021.  
  1022.  
  1023. int 
  1024.   DefaultPlayAtSpeedDir(VideoObject*    theObject,
  1025.             int        framesPerSecond,
  1026.             enum Direction    direction)
  1027. {
  1028.   fprintf(stderr, "DevPlayAtSpeedDir has not been implemented.\n");
  1029.   return Ok;
  1030. }
  1031.  
  1032.  
  1033. int DefaultStep(VideoObject*    theObject,
  1034.         enum Direction    direction)
  1035. {
  1036.   fprintf(stderr, "DevStep has not been implemented.\n");
  1037.   return Ok;
  1038. }
  1039.  
  1040.  
  1041. int DefaultStill(VideoObject* theObject)
  1042. {
  1043.   fprintf(stderr, "DevStill has not been implemented.\n");
  1044.   return Ok;
  1045. }
  1046.  
  1047. int DefaultStop(VideoObject* theObject)
  1048. {
  1049.   fprintf(stderr, "DevStop has not been implemented.\n");
  1050.   return Ok;
  1051. }
  1052.  
  1053. int DefaultSetDefaults(VideoObject*    theObject,
  1054.                int        audio,
  1055.                int        addressingMode,
  1056.                int        addressDisplayOnOff,
  1057.                int        displayMode)
  1058. {
  1059.   fprintf(stderr, "DevSetDefaults has not been implemented.\n");
  1060.   return Ok;
  1061. }
  1062.  
  1063. int DefaultSetAudio(VideoObject*    theObject,
  1064.             int            setting)
  1065. {
  1066.   fprintf(stderr, "DevSetAudio has not been implemented.\n");
  1067.   return Ok;
  1068. }
  1069.  
  1070. int DefaultSetVideo(VideoObject*    theObject,
  1071.             int            setting)
  1072. {  
  1073.   fprintf(stderr, "DevSetVideo has not been implemented.\n");
  1074.   return Ok;
  1075. }
  1076.  
  1077. int DefaultSetAddMode(VideoObject*    theObject,
  1078.               int         mode)
  1079. {
  1080.   fprintf(stderr, "DevSetAddMode has not been implemented.\n");
  1081.   return Ok;
  1082. }
  1083.  
  1084. int DefaultSetAddressDisplay(VideoObject*    theObject,
  1085.                  int        onOff,
  1086.                  int        mode)
  1087. {
  1088.   fprintf(stderr, "DevSetAddressDisplay has not been implemented.\n");
  1089.   return Ok;
  1090. }
  1091.  
  1092.  
  1093.  
  1094. int DefaultEject(VideoObject* theObject)
  1095. {
  1096.   fprintf(stderr, "DevEject has not been implemented.\n");
  1097.   return Ok;
  1098. }
  1099.  
  1100.  
  1101. int DefaultPower(VideoObject*    theObject,
  1102.          int        mode)
  1103. {
  1104.   fprintf(stderr, "DevPower has not been implemented.\n");
  1105.   return Ok;
  1106. }
  1107.  
  1108.  
  1109. int DefaultQueryFrame(VideoObject* theObject)
  1110. {
  1111.   fprintf(stderr, "DevQueryFrame has not been implemented.\n");
  1112.   return Ok;
  1113. }
  1114.  
  1115. int DefaultQueryChapter(VideoObject* theObject)
  1116. {
  1117.   fprintf(stderr, "DevQueryChapter has not been implemented.\n");
  1118.   return Ok;
  1119. }
  1120.  
  1121. int DefaultQueryAudio(VideoObject* theObject)
  1122. {
  1123.   fprintf(stderr, "DevQueryAudio has not been implemented.\n");
  1124.   return Ok;
  1125. }
  1126.  
  1127. int DefaultQueryVideo(VideoObject* theObject)
  1128. {
  1129.   fprintf(stderr, "DevQueryVideo has not been implemented.\n");
  1130.   return Ok;
  1131. }
  1132.  
  1133. int DefaultQueryMedium(VideoObject*    theObject,
  1134.                char*        result)
  1135. {
  1136.   fprintf(stderr, "DevQueryMedium has not been implemented.\n");
  1137.   return Ok;
  1138. }
  1139.  
  1140. int DefaultQueryStatus(VideoObject* theObject)
  1141. {
  1142.   fprintf(stderr, "DevQueryStatus has not been implemented.\n");
  1143.   return Ok;
  1144. }
  1145.  
  1146. int DefaultPing(VideoObject* theObject)
  1147. {
  1148.   fprintf(stderr, "DevPing has not been implemented.\n");
  1149.   return Ok;
  1150. }
  1151.  
  1152.  
  1153.  
  1154. int DefaultRecord(VideoObject* theObject)
  1155. {
  1156.   fprintf(stderr, "DevRecord has not been implemented.\n");
  1157.   return Ok;
  1158. }
  1159.  
  1160.  
  1161. int 
  1162.   DefaultRecordFromTo(VideoObject* theObject,
  1163.               int startFrame,
  1164.               int endFrame,
  1165.               int speed)
  1166. {
  1167.   fprintf(stderr, "DevRecordFromTo has not been implemented.\n");
  1168.   return Ok;
  1169. }
  1170.